#ifndef ___GraphWidget_h__inluded___
#define ___GraphWidget_h__inluded___

#include <QWidget>
#include <QMouseEvent>

#define PI=3.14159265358979323846 

//! Class for drawing an analog graph
class GraphWidget : public QWidget
{
    public:

	//! Default constructor
	GraphWidget( QWidget * parent = 0 );

	//! Set the background color for the graph
	void setBackgroundColor( QColor & color );
	//! Add a point to be graphed (TODO)
	void addPoint( float value );
	//! Draw the graph
	void draw();

	void setScale( int min, int max );  //!<  Set minimum and maximum values

    public slots:

	//! Slot to add a point to graph.
	void onNewPoint( float value );
	    

    protected:

	//! Does the actual drawing of the widget
	void paintEvent( QPaintEvent * event );
	//! Handles mouse move, in this test, uses it to set graph value
	virtual void mouseMoveEvent( QMouseEvent * event );

	//! Draws the needle on the graph
	void drawNeedle( QPainter & painter, double radius, double cx, double cy );

    private:

	//! Calculates x and y points, and I don't remember why :)
	void calcCirclePoints( int cx, int cy, int rad, int &x, int &y );

	QColor _bg_color;
	QPoint _cursor;

	//! The constant, pi
	double _pi;

	//! Where the scale should start drawing, in degrees
	double _scale_start;
	double _scale_degrees;    //!< The number of degrees the scale displays

	double _scale_min;	//!< The minimum value on the scale
	double _scale_max;	//!< The maximum value on the scale
	double _scale_delta;	//!< The difference between the maximum and minimum values

	double _cur_value;	//!< The current value being displayed by the graph.
};


#endif  // ___GraphWidget_h__inluded___
